import { http } from '@/utils/http/axios';

export interface BasicResponseModel<T = any> {
  code: number;
  message: string;
  result: T;
}

export interface BasicPageParams {
  pageNumber: number;
  pageSize: number;
  total: number;
}

export function getHousePage(params) {
  return http.request({
    url: '/house/page',
    method: 'get',
    params,
  });
}

export function getSearchHousePage(params) {
  return http.request({
    url: '/house/search2',
    method: 'get',
    params,
  });
}

export function getCategory() {
  return http.request({
    url: '/category/getCategory',
    method: 'get',
  });
}

export function deleteHouse(id) {
  return http.request<BasicResponseModel>({
    url: `/house/${id}`,
    method: 'DELETE',
  });
}

export function deleteHouseImg(id) {
  return http.request<BasicResponseModel>({
    url: `/houseImg/${id}`,
    method: 'DELETE',
  });
}

export function getCategoryList() {
  return http.request<BasicResponseModel>({
    url: `/category/getCategoryLabelValue`,
    method: 'GET',
  });
}

export function getPropertyList() {
  return http.request<BasicResponseModel>({
    url: `/property/label`,
    method: 'GET',
  });
}

export function getPropertyByHouseId(id) {
  return http.request<BasicResponseModel>({
    url: `/houseProperty/label/${id}`,
    method: 'GET',
  });
}

export function getHouseById(id) {
  return http.request<BasicResponseModel>({
    url: `/house/${id}`,
    method: 'GET',
  });
}
export function getHouseImgByHouseId(id) {
  return http.request<BasicResponseModel>({
    url: `/houseImg/house/${id}`,
    method: 'GET',
  });
}

export function addHouse(params) {
  return http.request<BasicResponseModel>({
    url: '/house/admin',
    method: 'POST',
    params,
  });
}

export function addHouseImg(params) {
  return http.request<BasicResponseModel>({
    url: '/houseImg',
    method: 'POST',
    params,
  });
}

export function addHouseProperty(params) {
  return http.request<BasicResponseModel>({
    url: '/houseProperty',
    method: 'POST',
    params,
  });
}

export function updateHouse(params) {
  return http.request<BasicResponseModel>({
    url: '/house',
    method: 'PUT',
    params,
  });
}
